<?php

    class MessageController{
        private $model;

        public function __construct(){
            $this->model = new MessageModel();
        }

//    插入与展示留言
    public function addShow(){
            if($_SERVER['REQUEST_METHOD'] == 'POST'){
                $name = $_POST['name'];
                $message = $_POST['content'];
//                echo $name,$message;
                if($this->model->addMessage($name,$message)){

                }else{echo '插入错误！';}
            }
//            var_dump($this->model->addMessage($name,$message));




//           计算展示的那十条留言
            $limit = 10;
            $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
            $start = ($page-1)* $limit;
            $message = $this->model->getMessage($start,$limit);

//            计算会有多少页
            $total = $this->model->countMessage();
            $totalPage = ceil($total/$limit);

            include 'app/views/indexView.php';

        }

    }

?>